package com.zhuoyue.biz.core.api.domain;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zhuoyue.biz.core.api.domain.base.BaseDoClass;
import lombok.*;

import java.time.LocalDateTime;

/**
 * 设备实体类
 *
 * @author Administrator
 */
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "`tbl_device`")
public class DeviceDO extends BaseDoClass {

    /**
     * ZigBee设备所属网关ID
     */
    @TableField(value = "`gateway_id`")
    private String gatewayId;


    /**
     * ZigBee设备所属网关MAC
     */

    @TableField(value = "`gateway_mac`", exist = false)
    private String gatewayMac;

    /**
     * 所属房间ID
     */
    @TableField(value = "`room_id`", updateStrategy = FieldStrategy.IGNORED)
    private String roomId;

    /**
     * ZigBee设备模块mac地址
     */
    @TableField(value = "`zigbee_mac`")
    private String zigbeeMac;

    @TableField(value = "`od_index`")
    private String odIndex;

    @TableField(value = "`device_type`")
    private String deviceType;

    @TableField(value = "`product_type`")
    private String productType;

    /**
     * 设备名称
     */
    @TableField(value = "`name`")
    private String name;

    @TableField(value = "`img_url`")
    private String imgUrl;

    /**
     * 设备类型 1：ZigBee设备；2：WIFI设备
     */
    @TableField(value = "`type`")
    private Integer type;


    /**
     * 状态
     */

    @TableField(value = "`switch_state`")
    private String switchState;


    /**
     * 设备状态时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(value = "`switch_time`")
    private LocalDateTime switchTime;

    @TableField(value = "`lwbz`")
    private String lwbz;

    @TableField(value = "`pushType`")
    private String pushType;

    @TableField(value = "`spreading_type`")
    private String spreadingType;

    /**
     * 产品id的信息
     */
    @TableField(value = "`prod_id`")
    private String prodId;
    /**
     * 所属房间名称
     */
    @TableField(exist = false)
    private String roomName;

    /**
     * 状态属性
     */
    @TableField(exist = false)
    private String actions;

    /**
     * 现在时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(exist = false)
    private LocalDateTime nowTime;


    /**
     * 获取具体设备类型
     *
     * @return
     */
    public String getOdAndDeviceTypeAndProType() {
        return this.odIndex + this.deviceType + this.productType;
    }
}
